"""
@author: 一切、會恏
@file: learn_mysql.py
@time: 2019/3/26 18:18
"""
#操作mysql
#pip install pymysql  或者pip install mysql-connector
#数据库连接信息：
#47.107.168.87  端口3306 用户名：python 密码：python666

from mysql import connector
#第一步：链接数据库 提供数据库的链接信息
db_config = {"host":"47.107.168.87",
             "user":"python",
             "password":"python666",
             "port":3306,
             "database":"future"
             }
conn = connector.connect(**db_config)#连接数据库

#第二步 获取游标，获取操作数据库的权限
cur = conn.cursor()#设置游标的位置

#第三步，操作数据表
query = "select * from member where RegName='小蜜蜂'"#sql查询语句
cur.execute(query)#执行sql查询

#第四步，获取查询的结果并打印结果 readline  readlines
res = cur.fetchone()#返回元祖
res1 = cur.fetchall()#返回嵌套元祖
print(res)
print(res1)
conn.close()